﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NumberParser
{
    public class Digit
    {
        List<Line> lines;

        public Digit(int number)
        {
            lines = new List<Line>(4);
        }

        public bool AddLine(Line line)
        {
            if (lines.Capacity > lines.Count)
            {
                lines.Add(line);
                return true;
            }
            return false;
        }

        public List<Line> Lines
        { get { return this.lines; } }

        public bool Matches(Digit digitToMatch)
        {
            for (int i = 0; i < lines.Count; i++)
            {
                if (!lines[i].Matches(digitToMatch.Lines[i]))
                    return false;
            }
            return true;
        }

        public override string ToString()
        {
            string result = string.Empty;
            foreach (var item in lines)
            {
                result += item.ToString() + "\r\n";
            }
            return result;
        }
    }
}
